package com.yanqu.road.server.manager.tomb.entity;

import com.yanqu.road.dao.dbV2.BaseEntity;
import com.yanqu.road.dao.dbV2.IField;
import com.yanqu.road.dao.dbV2.ITable;
import com.yanqu.road.dao.dbV2.serializer.DInt;
import com.yanqu.road.dao.dbV2.serializer.DLong;
import com.yanqu.road.dao.dbV2.serializer.DString;
import com.yanqu.road.pb.tomb.Tomb;
import com.yanqu.road.server.manager.tomb.TombActivity;

@ITable(tableName = "t_c_activity_tomb_log")

public class DbTombLog extends BaseEntity {

    public static DbTombLog newInstance() {
        return new DbTombLog();
    }

    @IField(isPrimaryKey = true, isAutoIncrement = true, fieldName = "id", serializer = DLong.class)
    public long id;
    @IField(index = "idx_uid", fieldName = "activity_id", serializer = DInt.class)
    public int activityId;

    @IField(index = "idx_uid", fieldName = "uid", serializer = DString.class)
    public String uid;

    @IField(fieldName = "from_user_id", serializer = DLong.class)
    public long fromUserId;
    @IField(fieldName = "to_user_id", serializer = DLong.class)
    public long toUserId;
    @IField(fieldName = "log_enum", serializer = DInt.class)
    public int logEnum;
    @IField(fieldName = "rewards", serializer = DString.class)
    public String rewards = "";


    @IField(fieldName = "energy_change", comment = "体力变更", serializer = DLong.class)
    public long energyChange;

    @IField(fieldName = "energy", comment = "剩余体力", serializer = DLong.class)
    public long energy;

    @IField(fieldName = "event_id", comment = "事件ID", serializer = DInt.class)
    public int eventId;

    @IField(fieldName = "floor", serializer = DInt.class)
    public int floor;
    @IField(fieldName = "x", serializer = DInt.class)
    public int x;
    @IField(fieldName = "y", serializer = DInt.class)
    public int y;

    @IField(fieldName = "value", serializer = DLong.class)
    public long value;
    @IField(fieldName = "value_1", serializer = DLong.class)
    public long value1;

    @IField(fieldName = "status", serializer = DInt.class)
    public int status;

    @IField(fieldName = "description", serializer = DString.class)
    public String description = "";

    @IField(fieldName = "groupId", serializer = DInt.class, comment = "分组")
    public int groupId;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getRewards() {
        return rewards;
    }

    public void setRewards(String rewards) {
        this.rewards = rewards;
    }

    public int getFloor() {
        return floor;
    }

    public void setFloor(int floor) {
        this.floor = floor;
    }

    public long getValue() {
        return value;
    }

    public void setValue(long value) {
        this.value = value;
    }

    public long getValue1() {
        return value1;
    }

    public void setValue1(int value1) {
        this.value1 = value1;
    }


    public int getLogEnum() {
        return logEnum;
    }

    public void setLogEnum(int logEnum) {
        this.logEnum = logEnum;
    }

    public long getFromUserId() {
        return fromUserId;
    }

    public void setFromUserId(long fromUserId) {
        this.fromUserId = fromUserId;
    }

    public long getToUserId() {
        return toUserId;
    }

    public void setToUserId(long toUserId) {
        this.toUserId = toUserId;
    }

    public void setValue1(long value1) {
        this.value1 = value1;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }


    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }




    public long getEnergyChange() {
        return energyChange;
    }

    public void setEnergyChange(long energyChange) {
        this.energyChange = energyChange;
    }

    public long getEnergy() {
        return energy;
    }

    public void setEnergy(long energy) {
        this.energy = energy;
    }

    public int getEventId() {
        return eventId;
    }

    public void setEventId(int eventId) {
        this.eventId = eventId;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Tomb.TombUserLogTemp.Builder toTempBuilder(TombActivity activity) {
        Tomb.TombUserLogTemp.Builder builder = Tomb.TombUserLogTemp.newBuilder();
        builder.setLogEnum(this.getLogEnum());
        builder.setValue(this.getValue());
        builder.setRewards(this.getRewards());
        builder.setValue1((int) this.getValue1());
        builder.setFloor(this.getFloor());
        DbTombUser dbTombUser = activity.getDbData().getDbTombUser(this.getFromUserId());
        if (dbTombUser != null) {
            builder.setFrom(dbTombUser.toEventUserInfoBuilder());
        }

        DbTombUser dbTombUser1 = activity.getDbData().getDbTombUser(this.getToUserId());
        if (dbTombUser1 != null) {
            builder.setTo(dbTombUser1.toEventUserInfoBuilder());
        }

        builder.setIsKill(this.status == 1);
        builder.setCreateTimeUnix(this.getCreateTime());
        return builder;
    }


    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        this.groupId = groupId;
    }
}
